package com.nlp.trie.lbt;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LbtTag {
	Map<String, String[]> lexicon = new HashMap<String, String[]>();
	public List<String> tag(List<String> words){
		List<String> ret = new ArrayList<String>(words.size());
		for (int i = 0, size = words.size(); i < size; i++) {
			String[] ss = lexicon.get(words.get(i));
			if (ss == null) {
				ss = lexicon.get(words.get(i).toLowerCase());
			}
			if (ss == null && words.get(i).length() == 1) {
				ret.add(words.get(i)+"^");
			}
			if (ss == null) {
				ret.add("NN");
			}else {
				ret.add(ss[0]);
			}
		}
		
		for (int i = 0; i < words.size(); i++) {
			String word = ret.get(i);
			if (i > 0 && ret.get(i-1).equals("DT")) {
				if (word.equals("VBD")
						|| word.equals("VBP")
						|| word.equals("VB")) {
					ret.set(i, "NN");
				}
			}
		}
		
		return ret;
	}

}
